package com.sjx.boundarycallback.oldrefresh;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.sjx.boundarycallback.R;

/**
 * Created by sjx on 2022/7/27
 * 头部视图管理器
 */
public class SelfHeadViewManager {

    private Context mContext;
    private View selfHeadView;

    public SelfHeadViewManager(Context context) {
        this.mContext = context;
    }

    public View getSelfHeadView() {
        if (selfHeadView == null) {
            selfHeadView = View.inflate(mContext, R.layout.header_refresh, null);
            selfHeadView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        }
        return selfHeadView;
    }

    public int getSelfHeadViewHeight() {
        /* 只要传入两个0就可以对子视图进行实际测量 */
        selfHeadView.measure(0, 0);
        int selfHeadViewHeight = selfHeadView.getMeasuredHeight();
        return selfHeadViewHeight;
    }

}
